<{include file="public/header.html"}>
<link rel="stylesheet" type="text/css" href="/static/default/css/index.css"/>
<link rel="stylesheet" type="text/css" href="/static/default/css/common.css"/>
<script src="/static/public/jquery.pagination.js" type="text/javascript" charset="utf-8"></script>
<div class="credit-main w1180-con mt20">
    <div class="mb20" style="height: 193px; background: url(/static/default/img/introduce/4.jpg) no-repeat center 0;">
    </div>
    <div class="clear"></div>
    <!--信用卡列表-->
    <div class="credit-card-list">


    </div>
    <div class="holder" id="credit_pagination"></div>
</div>

<script type="text/javascript">

    function showCreditInfo(ID){
        var params = {};
        params.id = ID;
        doRequest("/task/info.html",params,false,function(data){$("body").find(".popup-credit,.popup-credit-sign").remove().end().append(data.data);layer.msg("余额不足哦！",{icon:0,time:1000,offset:300});},errorCallback);
    }
    function ajaxApply(tid){
        var params = {};
        params.tid = tid;
        doRequest("/task/ajax_apply.html",params,false,function(data){
            $("body").find(".popup-credit,.popup-credit-sign").remove().end().append(data.data);
            layer.msg(data.msg,{icon:0,time:1000,offset:300});

            setTimeout(function(

            ){
                window.open(data.link);
            },1000);


        },errorCallback);
    }
    function successLoadCredit(resp){
        var totalCount = resp.data.totalCount;
        var str = "";
        if(totalCount == 0){
            str += "<div class='no-card'><b class='icon icon-hasno'></b>没有找到符合您筛选条件的信用卡，您可以重新选择!</div>";
        }
        var list = resp.data.list;
        $.each(list,function(index,data){
            str +=  data.str;
        });

        $(".credit-card-list").html(str);
        creditPage(totalCount,resp.data.pageIndex);
    }
    function loadCredit(pageIndex){
        var obj = $(".credit-classify .hover-style");
        var str = "";
        obj.each(function(){
            str += $(this).attr("data-id")+",";
        });
        str = str.substr(0,str.length-1);
        var params = {};
        params.type = str;
        params.pageIndex = pageIndex;
        doRequest("/task/mlist.html",params,false,successLoadCredit,errorCallback);
    }

    function creditPage(total,pageIndex){
        $("#credit_pagination").pagination(total, { //recordCount在后台定义的一个公有变量，通过从数据库查询记录进行赋值，返回记录的总数
            callback: loadCredit,  //点击分页时，调用的回调函数
            prev_text: '<',  //显示上一页按钮的文本
            next_text: '>',  //显示下一页按钮的文本
            link_to:"javascript:void(0);",
            items_per_page:10,  //每页显示的项数
            num_display_entries:6,  //分页插件中间显示的按钮数目
            current_page:pageIndex,  //当前页索引
            num_edge_entries:2  //分页插件左右两边显示的按钮数目
        });
    }

    /**
     * credit-card detail 弹窗
     * */
    $("body").delegate('.popup-credit-sign .icon-close','click',function(){
        $(this).parents('.popup-credit-sign').fadeOut();
        $('.popup-credit').fadeOut();
    });
    $("body").delegate('.popup-credit-sign .tab span','click',function(){
        index = $(this).parent().children().index($(this));
        $('.popup-credit-sign .credit-con .credit-txt').eq(index).fadeIn().siblings().hide();
        $(this).addClass('popup-credit-line').siblings().removeClass('popup-credit-line');
    });
    /**
     * credit-card 类别 click effect
     * */
    $(function(){
        loadCredit(0);
        var obj=$(".credit-classify.clear");
        obj.each(function()
        {
            var _this=this;
            $( "li a,.credit-selected.hover-style",this).click(function()
            {
                $( "li a,.credit-selected.hover-style",_this).removeClass("hover-style")
                $(this).addClass("hover-style");
                $(this).removeClass("hovering");

                loadCredit(0);
            })
        })
    });


</script>
<!--footer-->
<{include file="public/footer.html"}>